<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<title>Literal Lists</title>
<link href="../docs-assets/Breadcrumbs.css" rel="stylesheet" rev="stylesheet" type="text/css">
		<meta name="viewport" content="width=device-width initial-scale=1">
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<meta http-equiv="Content-Language" content="en-gb">

<link href="../docs-assets/Contents.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Progress.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Navigation.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Fonts.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Base.css" rel="stylesheet" rev="stylesheet" type="text/css">
<script>
function togglePopup(material_id) {
  var popup = document.getElementById(material_id);
  popup.classList.toggle("show");
}
</script>

<link href="../docs-assets/Popups.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Colours.css" rel="stylesheet" rev="stylesheet" type="text/css">
		
	</head>
	<body class="commentary-font">
		<nav role="navigation">
		<h1><a href="../index.html"><img src="../docs-assets/Inform.png" height=72> </a></h1>
<ul><li><a href="../index.html">home</a></li>
</ul><h2>Compiler</h2><ul>
<li><a href="../structure.html">structure</a></li>
<li><a href="../inbuildn.html">inbuild</a></li>
<li><a href="../inform7n.html">inform7</a></li>
<li><a href="../intern.html">inter</a></li>
<li><a href="../services.html">services</a></li>
<li><a href="../secrets.html">secrets</a></li>
</ul><h2>Other Tools</h2><ul>
<li><a href="../inblorbn.html">inblorb</a></li>
<li><a href="../inform6.html">inform6</a></li>
<li><a href="../inpolicyn.html">inpolicy</a></li>
</ul><h2>Resources</h2><ul>
<li><a href="../extensions.html">extensions</a></li>
<li><a href="../kits.html">kits</a></li>
</ul><h2>Repository</h2><ul>
<li><a href="https://github.com/ganelson/inform"><img src="../docs-assets/github.png" height=0> github</a></li>
</ul><h2>Related Projects</h2><ul>
<li><a href="https://github.com/ganelson/inweb"><img src="../docs-assets/github.png" height=0> inweb</a></li>
<li><a href="https://github.com/ganelson/intest"><img src="../docs-assets/github.png" height=0> intest</a></li>
</ul>
		</nav>
		<main role="main">
		<!-- Weave of 'Literal Lists' generated by inweb -->
<div class="breadcrumbs">
    <ul class="crumbs"><li><a href="../index.html">Home</a></li><li><a href="../inform7n.html">Inform7</a></li><li><a href="index.html">values</a></li><li><a href="index.html#3">Chapter 3: Literals</a></li><li><b>Literal Lists</b></li></ul></div>
<p class="purpose">Parsing and vetting the kinds of literal lists written in braces.</p>

<p class="commentary firstcommentary"><a id="SP1" class="paragraph-anchor"></a><b>&#167;1. </b>Literal lists in Inform are written in braces: for example,
</p>

<blockquote>
    <p>let L be {2, 12, 13};</p>
</blockquote>

<p class="commentary">Here "{2, 12, 13}" is parsed to an rvalue specification. Various syntactic
things can go wrong with those commas and braces, which must be detected, and
Inform must also work out the kind &mdash; here, it's "list of numbers".
</p>

<p class="commentary">Note that the empty list "{}" is valid as a constant, but that it contains
no indication of its kind &mdash; this must be determined from context.
</p>

<p class="commentary">The following Preform grammar handles the syntax, at least:
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="function-syntax">&lt;s-literal-list&gt;</span>
<span class="plain-syntax">    \{ \} |</span>
<span class="plain-syntax">    \{ </span><span class="function-syntax">&lt;list-conts&gt;</span><span class="plain-syntax"> \}</span>

<span class="function-syntax">&lt;list-conts&gt;</span>
<span class="plain-syntax">    </span><span class="function-syntax">&lt;list-entry&gt;</span><span class="plain-syntax"> , </span><span class="function-syntax">&lt;list-conts&gt;</span><span class="plain-syntax"> |</span>
<span class="plain-syntax">    </span><span class="function-syntax">&lt;list-entry&gt;</span>

<span class="function-syntax">&lt;list-entry&gt;</span>
<span class="plain-syntax">    </span><span class="function-syntax">&lt;s-value&gt;</span><span class="plain-syntax"> |</span>
<span class="plain-syntax">    ......</span>
</pre>
<p class="commentary firstcommentary"><a id="SP2" class="paragraph-anchor"></a><b>&#167;2. </b>And the result of this grammar, if it matches, is an rvalue made thus:
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="identifier-syntax">parse_node</span><span class="plain-syntax"> *</span><span class="function-syntax">Lists::at</span><button class="popup" onclick="togglePopup('usagePopup1')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup1">Usage of <span class="code-font"><span class="function-syntax">Lists::at</span></span>:<br/><a href="3-ll.html#SP1">&#167;1</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">literal_list</span><span class="plain-syntax"> *</span><span class="identifier-syntax">L</span><span class="plain-syntax">, </span><span class="identifier-syntax">wording</span><span class="plain-syntax"> </span><span class="identifier-syntax">W</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><a href="2-rvl.html#SP16" class="function-link"><span class="function-syntax">Rvalues::from_wording_of_list</span></a><span class="plain-syntax">(</span><a href="3-ll.html#SP8" class="function-link"><span class="function-syntax">Lists::kind_of_ll</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">L</span><span class="plain-syntax">, </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">), </span><span class="identifier-syntax">W</span><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP3" class="paragraph-anchor"></a><b>&#167;3. </b>Each different literal list (LL) found in the source text generates an
instance of the following structure. Note that:
</p>

<ul class="items"><li>(1) every LL structure represents a syntactically well-formed list, in which
braces and commas balance; and
</li><li>(2) there can be at most one LL structure at any word position.
</li></ul>
<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">typedef</span><span class="plain-syntax"> </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="reserved-syntax">literal_list</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">wording</span><span class="plain-syntax"> </span><span class="identifier-syntax">unbraced_text</span><span class="plain-syntax">; </span><span class="comment-syntax"> position in the source of quoted text, excluding braces</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">parse_node</span><span class="plain-syntax"> *</span><span class="identifier-syntax">list_text</span><span class="plain-syntax">; </span><span class="comment-syntax"> used for problem reporting only</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">listed_within_code</span><span class="plain-syntax">; </span><span class="comment-syntax"> appears within a phrase, rather than (say) a table entry?</span>

<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> *</span><span class="identifier-syntax">entry_kind</span><span class="plain-syntax">; </span><span class="comment-syntax"> i.e., of the entries, not the list</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">kinds_known_to_be_inconsistent</span><span class="plain-syntax">; </span><span class="comment-syntax"> problem(s) thrown when parsing these</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">explicitly_cast</span><span class="plain-syntax">; </span><span class="comment-syntax"> has reading a wider context determined the kind?</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="reserved-syntax">llist_entry</span><span class="plain-syntax"> *</span><span class="identifier-syntax">first_llist_entry</span><span class="plain-syntax">; </span><span class="comment-syntax"> linked list of contents</span>

<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">package_request</span><span class="plain-syntax"> *</span><span class="identifier-syntax">ll_package</span><span class="plain-syntax">; </span><span class="comment-syntax"> which will be the enclosure for...</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">inter_name</span><span class="plain-syntax"> *</span><span class="identifier-syntax">ll_iname</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">CLASS_DEFINITION</span>
<span class="plain-syntax">} </span><span class="reserved-syntax">literal_list</span><span class="plain-syntax">;</span>
</pre>
<ul class="endnotetexts"><li>The structure literal_list is private to this section.</li></ul>
<p class="commentary firstcommentary"><a id="SP4" class="paragraph-anchor"></a><b>&#167;4. </b>I believe "llath" is the Welsh word for "yard": not sure about "llist".
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">typedef</span><span class="plain-syntax"> </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="reserved-syntax">llist_entry</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">parse_node</span><span class="plain-syntax"> *</span><span class="identifier-syntax">llist_entry_value</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="reserved-syntax">llist_entry</span><span class="plain-syntax"> *</span><span class="identifier-syntax">next_llist_entry</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">CLASS_DEFINITION</span>
<span class="plain-syntax">} </span><span class="reserved-syntax">llist_entry</span><span class="plain-syntax">;</span>
</pre>
<ul class="endnotetexts"><li>The structure llist_entry is private to this section.</li></ul>
<p class="commentary firstcommentary"><a id="SP5" class="paragraph-anchor"></a><b>&#167;5. </b>These structures are built incrementally, adding one <span class="extract"><span class="extract-syntax">llist_entry</span></span> at a time.
They begin with a call to:
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">literal_list</span><span class="plain-syntax"> *</span><span class="function-syntax">Lists::empty_literal</span><button class="popup" onclick="togglePopup('usagePopup2')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup2">Usage of <span class="code-font"><span class="function-syntax">Lists::empty_literal</span></span>:<br/><a href="3-ll.html#SP1">&#167;1</a></span></button><span class="plain-syntax">(</span><span class="identifier-syntax">wording</span><span class="plain-syntax"> </span><span class="identifier-syntax">W</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">literal_list</span><span class="plain-syntax"> *</span><span class="identifier-syntax">ll</span><span class="plain-syntax"> = </span><a href="3-ll.html#SP6" class="function-link"><span class="function-syntax">Lists::find_literal</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">Wordings::first_wn</span><span class="plain-syntax">(</span><span class="identifier-syntax">W</span><span class="plain-syntax">));</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">ll</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) </span><span class="identifier-syntax">ll</span><span class="plain-syntax"> = </span><span class="identifier-syntax">CREATE</span><span class="plain-syntax">(</span><span class="reserved-syntax">literal_list</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">ll</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">unbraced_text</span><span class="plain-syntax"> = </span><span class="identifier-syntax">W</span><span class="plain-syntax">; </span><span class="identifier-syntax">ll</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">entry_kind</span><span class="plain-syntax"> = </span><span class="identifier-syntax">K_nil</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">ll</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">listed_within_code</span><span class="plain-syntax"> = </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">ll</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">kinds_known_to_be_inconsistent</span><span class="plain-syntax"> = </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">ll</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">ll_iname</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">ll</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">first_llist_entry</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">ll</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">explicitly_cast</span><span class="plain-syntax"> = </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">ll</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">list_text</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">ll</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">ll_package</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Emit::current_enclosure</span><span class="plain-syntax">();</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">TheHeap::ensure_basic_heap_present</span><span class="plain-syntax">();</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">ll</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP6" class="paragraph-anchor"></a><b>&#167;6. </b>Parsing is quadratic in the number of constant lists in the source text,
which is in principle a bad thing, but in practice the following causes no
speed problems even on large-scale tests. If it becomes a problem, we can
easily trade the time spent here for memory, by attaching a pointer to
each word in the source text, or for complexity, by constructing some kind
of binary search tree.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">literal_list</span><span class="plain-syntax"> *</span><span class="function-syntax">Lists::find_literal</span><button class="popup" onclick="togglePopup('usagePopup3')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup3">Usage of <span class="code-font"><span class="function-syntax">Lists::find_literal</span></span>:<br/><a href="3-ll.html#SP5">&#167;5</a>, <a href="3-ll.html#SP7">&#167;7</a>, <a href="3-ll.html#SP9">&#167;9</a>, <a href="3-ll.html#SP10">&#167;10</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">incipit</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">literal_list</span><span class="plain-syntax"> *</span><span class="identifier-syntax">ll</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">LOOP_OVER</span><span class="plain-syntax">(</span><span class="identifier-syntax">ll</span><span class="plain-syntax">, </span><span class="reserved-syntax">literal_list</span><span class="plain-syntax">)</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Wordings::first_wn</span><span class="plain-syntax">(</span><span class="identifier-syntax">ll</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">unbraced_text</span><span class="plain-syntax">) == </span><span class="identifier-syntax">incipit</span><span class="plain-syntax">)</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">ll</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP7" class="paragraph-anchor"></a><b>&#167;7. </b>Note that the entry kind is initially unknown, and it's not even decided
for sure when we add the first entry. Here's how each entry is added,
recursing right to left (i.e., reversing the direction of reading):
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">literal_list</span><span class="plain-syntax"> *</span><span class="function-syntax">Lists::add</span><button class="popup" onclick="togglePopup('usagePopup4')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup4">Usage of <span class="code-font"><span class="function-syntax">Lists::add</span></span>:<br/><a href="3-ll.html#SP1">&#167;1</a></span></button><span class="plain-syntax">(</span><span class="identifier-syntax">parse_node</span><span class="plain-syntax"> *</span><span class="identifier-syntax">spec</span><span class="plain-syntax">, </span><span class="reserved-syntax">literal_list</span><span class="plain-syntax"> *</span><span class="identifier-syntax">ll</span><span class="plain-syntax">, </span><span class="identifier-syntax">wording</span><span class="plain-syntax"> </span><span class="identifier-syntax">W</span><span class="plain-syntax">, </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">bad</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">llist_entry</span><span class="plain-syntax"> *</span><span class="identifier-syntax">lle</span><span class="plain-syntax"> = </span><span class="identifier-syntax">CREATE</span><span class="plain-syntax">(</span><span class="reserved-syntax">llist_entry</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">lle</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">next_llist_entry</span><span class="plain-syntax"> = </span><span class="identifier-syntax">ll</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">first_llist_entry</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">ll</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">first_llist_entry</span><span class="plain-syntax"> = </span><span class="identifier-syntax">lle</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">lle</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">llist_entry_value</span><span class="plain-syntax"> = </span><span class="identifier-syntax">spec</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">literal_list</span><span class="plain-syntax"> *</span><span class="identifier-syntax">ll2</span><span class="plain-syntax"> = </span><a href="3-ll.html#SP6" class="function-link"><span class="function-syntax">Lists::find_literal</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">Wordings::first_wn</span><span class="plain-syntax">(</span><span class="identifier-syntax">W</span><span class="plain-syntax">));</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">ll2</span><span class="plain-syntax">) </span><span class="identifier-syntax">ll</span><span class="plain-syntax"> = </span><span class="identifier-syntax">ll2</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">ll</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">unbraced_text</span><span class="plain-syntax"> = </span><span class="identifier-syntax">W</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">bad</span><span class="plain-syntax">) </span><span class="identifier-syntax">ll</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">kinds_known_to_be_inconsistent</span><span class="plain-syntax"> = </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">ll</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP8" class="paragraph-anchor"></a><b>&#167;8. </b>With all the entries in place, we now have to reconcile their kinds, if
that's possible. Problems are only issued on request, and with the current
sentence cut down to just the list itself &mdash; since otherwise we might be
printing out an entire huge table to report a problem in a single entry
which happens to be a malformed list.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="identifier-syntax">kind</span><span class="plain-syntax"> *</span><span class="function-syntax">Lists::kind_of_ll</span><button class="popup" onclick="togglePopup('usagePopup5')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup5">Usage of <span class="code-font"><span class="function-syntax">Lists::kind_of_ll</span></span>:<br/><a href="3-ll.html#SP2">&#167;2</a>, <a href="3-ll.html#SP9">&#167;9</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">literal_list</span><span class="plain-syntax"> *</span><span class="identifier-syntax">ll</span><span class="plain-syntax">, </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">issue_problems</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">ll</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">explicitly_cast</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">Kinds::unary_con</span><span class="plain-syntax">(</span><span class="identifier-syntax">CON_list_of</span><span class="plain-syntax">, </span><span class="identifier-syntax">ll</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">entry_kind</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">parse_node</span><span class="plain-syntax"> *</span><span class="identifier-syntax">cs</span><span class="plain-syntax"> = </span><span class="identifier-syntax">current_sentence</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">issue_problems</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">ll</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">list_text</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">)</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">ll</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">list_text</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Diagrams::new_UNPARSED_NOUN</span><span class="plain-syntax">(</span><span class="identifier-syntax">ll</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">unbraced_text</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">current_sentence</span><span class="plain-syntax"> = </span><span class="identifier-syntax">ll</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">list_text</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> *</span><span class="identifier-syntax">K</span><span class="plain-syntax"> = </span><span class="identifier-syntax">K_nil</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">llist_entry</span><span class="plain-syntax"> *</span><span class="identifier-syntax">lle</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="identifier-syntax">lle</span><span class="plain-syntax"> = </span><span class="identifier-syntax">ll</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">first_llist_entry</span><span class="plain-syntax">; </span><span class="identifier-syntax">lle</span><span class="plain-syntax">; </span><span class="identifier-syntax">lle</span><span class="plain-syntax"> = </span><span class="identifier-syntax">lle</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">next_llist_entry</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">parse_node</span><span class="plain-syntax"> *</span><span class="identifier-syntax">spec</span><span class="plain-syntax"> = </span><span class="identifier-syntax">lle</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">llist_entry_value</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (!</span><span class="identifier-syntax">Node::is</span><span class="plain-syntax">(</span><span class="identifier-syntax">spec</span><span class="plain-syntax">, </span><span class="identifier-syntax">UNKNOWN_NT</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">AConditions::is_action_TEST_VALUE</span><span class="plain-syntax">(</span><span class="identifier-syntax">spec</span><span class="plain-syntax">))</span>
<span class="plain-syntax">                </span><a href="5-dsh.html#SP8" class="function-link"><span class="function-syntax">Dash::check_value_silently</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">spec</span><span class="plain-syntax">, </span><span class="identifier-syntax">K_stored_action</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">else</span>
<span class="plain-syntax">                </span><a href="5-dsh.html#SP8" class="function-link"><span class="function-syntax">Dash::check_value_silently</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">spec</span><span class="plain-syntax">, </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">spec</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NonlocalVariables::substitute_constants</span><span class="plain-syntax">(</span><span class="identifier-syntax">spec</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> *</span><span class="identifier-syntax">E</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="named-paragraph-container code-font"><a href="3-ll.html#SP8_1" class="named-paragraph-link"><span class="named-paragraph">Work out the entry kind E</span><span class="named-paragraph-number">8.1</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Kinds::eq</span><span class="plain-syntax">(</span><span class="identifier-syntax">K</span><span class="plain-syntax">, </span><span class="identifier-syntax">K_nil</span><span class="plain-syntax">)) </span><span class="identifier-syntax">K</span><span class="plain-syntax"> = </span><span class="identifier-syntax">E</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="named-paragraph-container code-font"><a href="3-ll.html#SP8_2" class="named-paragraph-link"><span class="named-paragraph">Revise K in the light of E</span><span class="named-paragraph-number">8.2</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">ll</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">kinds_known_to_be_inconsistent</span><span class="plain-syntax">) </span><span class="identifier-syntax">K</span><span class="plain-syntax"> = </span><span class="identifier-syntax">K_nil</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">ll</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">entry_kind</span><span class="plain-syntax"> = </span><span class="identifier-syntax">K</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">current_sentence</span><span class="plain-syntax"> = </span><span class="identifier-syntax">cs</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">Kinds::unary_con</span><span class="plain-syntax">(</span><span class="identifier-syntax">CON_list_of</span><span class="plain-syntax">, </span><span class="identifier-syntax">K</span><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP8_1" class="paragraph-anchor"></a><b>&#167;8.1. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Work out the entry kind E</span><span class="named-paragraph-number">8.1</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Node::is</span><span class="plain-syntax">(</span><span class="identifier-syntax">spec</span><span class="plain-syntax">, </span><span class="identifier-syntax">UNKNOWN_NT</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">issue_problems</span><span class="plain-syntax">) </span><span class="named-paragraph-container code-font"><a href="3-ll.html#SP8_1_1" class="named-paragraph-link"><span class="named-paragraph">Issue a bad list entry problem</span><span class="named-paragraph-number">8.1.1</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">ll</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">kinds_known_to_be_inconsistent</span><span class="plain-syntax"> = </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">E</span><span class="plain-syntax"> = </span><span class="identifier-syntax">K</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">Node::is</span><span class="plain-syntax">(</span><span class="identifier-syntax">spec</span><span class="plain-syntax">, </span><span class="identifier-syntax">CONSTANT_NT</span><span class="plain-syntax">) == </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">) &amp;&amp;</span>
<span class="plain-syntax">        (</span><a href="2-lvl.html#SP9" class="function-link"><span class="function-syntax">Lvalues::is_constant_NONLOCAL_VARIABLE</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">spec</span><span class="plain-syntax">) == </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">issue_problems</span><span class="plain-syntax">) </span><span class="named-paragraph-container code-font"><a href="3-ll.html#SP8_1_2" class="named-paragraph-link"><span class="named-paragraph">Issue a nonconstant list entry problem</span><span class="named-paragraph-number">8.1.2</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">ll</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">kinds_known_to_be_inconsistent</span><span class="plain-syntax"> = </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">E</span><span class="plain-syntax"> = </span><span class="identifier-syntax">K</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">E</span><span class="plain-syntax"> = </span><a href="2-spc.html#SP1" class="function-link"><span class="function-syntax">Specifications::to_kind</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">spec</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">E</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">issue_problems</span><span class="plain-syntax">) </span><span class="named-paragraph-container code-font"><a href="3-ll.html#SP8_1_1" class="named-paragraph-link"><span class="named-paragraph">Issue a bad list entry problem</span><span class="named-paragraph-number">8.1.1</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">ll</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">kinds_known_to_be_inconsistent</span><span class="plain-syntax"> = </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">    }</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="3-ll.html#SP8">&#167;8</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP8_2" class="paragraph-anchor"></a><b>&#167;8.2. </b>The following broadens K to include E, if necessary, but never narrows K.
Thus a list containing a person, a woman and a door will see K become
successively "person", "person" (E being narrower), then "thing" (E being
incomparable, and "thing" being the max of "person" and "door").
</p>

<p class="commentary"><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Revise K in the light of E</span><span class="named-paragraph-number">8.2</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> *</span><span class="identifier-syntax">previous_K</span><span class="plain-syntax"> = </span><span class="identifier-syntax">K</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">K</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Latticework::join</span><span class="plain-syntax">(</span><span class="identifier-syntax">E</span><span class="plain-syntax">, </span><span class="identifier-syntax">K</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Kinds::get_construct</span><span class="plain-syntax">(</span><span class="identifier-syntax">K</span><span class="plain-syntax">) != </span><span class="identifier-syntax">CON_phrase</span><span class="plain-syntax">)</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Kinds::Behaviour::definite</span><span class="plain-syntax">(</span><span class="identifier-syntax">K</span><span class="plain-syntax">) == </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">issue_problems</span><span class="plain-syntax">) </span><span class="named-paragraph-container code-font"><a href="3-ll.html#SP8_2_1" class="named-paragraph-link"><span class="named-paragraph">Issue a list entry kind mismatch problem</span><span class="named-paragraph-number">8.2.1</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">ll</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">kinds_known_to_be_inconsistent</span><span class="plain-syntax"> = </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">break</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        }</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="3-ll.html#SP8">&#167;8</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP8_1_1" class="paragraph-anchor"></a><b>&#167;8.1.1. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Issue a bad list entry problem</span><span class="named-paragraph-number">8.1.1</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="identifier-syntax">Problems::quote_source</span><span class="plain-syntax">(1, </span><span class="identifier-syntax">current_sentence</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">Problems::quote_wording</span><span class="plain-syntax">(2, </span><span class="identifier-syntax">Node::get_text</span><span class="plain-syntax">(</span><span class="identifier-syntax">spec</span><span class="plain-syntax">));</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">StandardProblems::handmade_problem</span><span class="plain-syntax">(</span><span class="identifier-syntax">Task::syntax_tree</span><span class="plain-syntax">(),</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">_p_</span><span class="plain-syntax">(</span><span class="identifier-syntax">PM_BadConstantListEntry</span><span class="plain-syntax">));</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">Problems::issue_problem_segment</span><span class="plain-syntax">(</span>
<span class="plain-syntax">        </span><span class="string-syntax">"The constant list %1 contains an entry '%2' which isn't any "</span>
<span class="plain-syntax">        </span><span class="string-syntax">"form of constant I'm able to read."</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">Problems::issue_problem_segment</span><span class="plain-syntax">(</span>
<span class="plain-syntax">        </span><span class="string-syntax">"%PNote that lists have to be written with spaces after commas, "</span>
<span class="plain-syntax">        </span><span class="string-syntax">"so I like '{2, 4}' but not '{2,4}', for instance."</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">Problems::issue_problem_end</span><span class="plain-syntax">();</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="3-ll.html#SP8_1">&#167;8.1</a> (twice).</li></ul>
<p class="commentary firstcommentary"><a id="SP8_1_2" class="paragraph-anchor"></a><b>&#167;8.1.2. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Issue a nonconstant list entry problem</span><span class="named-paragraph-number">8.1.2</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="identifier-syntax">Problems::quote_source</span><span class="plain-syntax">(1, </span><span class="identifier-syntax">current_sentence</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">Problems::quote_wording</span><span class="plain-syntax">(2, </span><span class="identifier-syntax">Node::get_text</span><span class="plain-syntax">(</span><span class="identifier-syntax">spec</span><span class="plain-syntax">));</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">Problems::quote_spec</span><span class="plain-syntax">(3, </span><span class="identifier-syntax">spec</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">StandardProblems::handmade_problem</span><span class="plain-syntax">(</span><span class="identifier-syntax">Task::syntax_tree</span><span class="plain-syntax">(),</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">_p_</span><span class="plain-syntax">(</span><span class="identifier-syntax">PM_NonconstantConstantListEntry</span><span class="plain-syntax">));</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">Problems::issue_problem_segment</span><span class="plain-syntax">(</span>
<span class="plain-syntax">        </span><span class="string-syntax">"The constant list %1 contains an entry '%2' which does make sense, "</span>
<span class="plain-syntax">        </span><span class="string-syntax">"but isn't a constant (it's %3). Only constants can appear as entries in "</span>
<span class="plain-syntax">        </span><span class="string-syntax">"constant lists, i.e., in lists written in braces '{' and '}'."</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">Problems::issue_problem_end</span><span class="plain-syntax">();</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="3-ll.html#SP8_1">&#167;8.1</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP8_2_1" class="paragraph-anchor"></a><b>&#167;8.2.1. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Issue a list entry kind mismatch problem</span><span class="named-paragraph-number">8.2.1</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="identifier-syntax">Problems::quote_source</span><span class="plain-syntax">(1, </span><span class="identifier-syntax">current_sentence</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">Problems::quote_wording</span><span class="plain-syntax">(2, </span><span class="identifier-syntax">Node::get_text</span><span class="plain-syntax">(</span><span class="identifier-syntax">spec</span><span class="plain-syntax">));</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">Problems::quote_kind</span><span class="plain-syntax">(3, </span><span class="identifier-syntax">E</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">Problems::quote_kind</span><span class="plain-syntax">(4, </span><span class="identifier-syntax">previous_K</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">StandardProblems::handmade_problem</span><span class="plain-syntax">(</span><span class="identifier-syntax">Task::syntax_tree</span><span class="plain-syntax">(),</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">_p_</span><span class="plain-syntax">(</span><span class="identifier-syntax">PM_IncompatibleConstantListEntry</span><span class="plain-syntax">));</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">Problems::issue_problem_segment</span><span class="plain-syntax">(</span>
<span class="plain-syntax">        </span><span class="string-syntax">"The constant list %1 contains an entry '%2' whose kind is '%3', but "</span>
<span class="plain-syntax">        </span><span class="string-syntax">"that's not compatible with the kind I had established from looking at "</span>
<span class="plain-syntax">        </span><span class="string-syntax">"earlier entries ('%4')."</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">Problems::issue_problem_end</span><span class="plain-syntax">();</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="3-ll.html#SP8_2">&#167;8.2</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP9" class="paragraph-anchor"></a><b>&#167;9. </b>The following allow other parts of Inform to find the kind of a constant
list at a given word position; either to discover the answer, or to force
problem messages out into the open &mdash;
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="identifier-syntax">kind</span><span class="plain-syntax"> *</span><span class="function-syntax">Lists::kind_of_list_at</span><button class="popup" onclick="togglePopup('usagePopup6')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup6">Usage of <span class="code-font"><span class="function-syntax">Lists::kind_of_list_at</span></span>:<br/>Rvalues - <a href="2-rvl.html#SP25_4">&#167;25.4</a></span></button><span class="plain-syntax">(</span><span class="identifier-syntax">wording</span><span class="plain-syntax"> </span><span class="identifier-syntax">W</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">incipit</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Wordings::first_wn</span><span class="plain-syntax">(</span><span class="identifier-syntax">W</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">literal_list</span><span class="plain-syntax"> *</span><span class="identifier-syntax">ll</span><span class="plain-syntax"> = </span><a href="3-ll.html#SP6" class="function-link"><span class="function-syntax">Lists::find_literal</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">incipit</span><span class="plain-syntax">+1);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">ll</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><a href="3-ll.html#SP8" class="function-link"><span class="function-syntax">Lists::kind_of_ll</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">ll</span><span class="plain-syntax">, </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>

<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">Lists::check_one</span><button class="popup" onclick="togglePopup('usagePopup7')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup7">Usage of <span class="code-font"><span class="function-syntax">Lists::check_one</span></span>:<br/>Dash - <a href="5-dsh.html#SP14_1_1_2">&#167;14.1.1.2</a></span></button><span class="plain-syntax">(</span><span class="identifier-syntax">wording</span><span class="plain-syntax"> </span><span class="identifier-syntax">W</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">incipit</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Wordings::first_wn</span><span class="plain-syntax">(</span><span class="identifier-syntax">W</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">literal_list</span><span class="plain-syntax"> *</span><span class="identifier-syntax">ll</span><span class="plain-syntax"> = </span><a href="3-ll.html#SP6" class="function-link"><span class="function-syntax">Lists::find_literal</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">incipit</span><span class="plain-syntax">+1);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">ll</span><span class="plain-syntax">) </span><a href="3-ll.html#SP8" class="function-link"><span class="function-syntax">Lists::kind_of_ll</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">ll</span><span class="plain-syntax">, </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP10" class="paragraph-anchor"></a><b>&#167;10. </b>The interpretation of an empty list at a given position in the source is
sometimes set by the assertion machinery, so we also need:
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">Lists::set_kind_of_list_at</span><span class="plain-syntax">(</span><span class="identifier-syntax">wording</span><span class="plain-syntax"> </span><span class="identifier-syntax">W</span><span class="plain-syntax">, </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> *</span><span class="identifier-syntax">K</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Kinds::get_construct</span><span class="plain-syntax">(</span><span class="identifier-syntax">K</span><span class="plain-syntax">) != </span><span class="identifier-syntax">CON_list_of</span><span class="plain-syntax">) </span><span class="identifier-syntax">internal_error</span><span class="plain-syntax">(</span><span class="string-syntax">"not a list kind"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">incipit</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Wordings::first_wn</span><span class="plain-syntax">(</span><span class="identifier-syntax">W</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">literal_list</span><span class="plain-syntax"> *</span><span class="identifier-syntax">ll</span><span class="plain-syntax"> = </span><a href="3-ll.html#SP6" class="function-link"><span class="function-syntax">Lists::find_literal</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">incipit</span><span class="plain-syntax">+1);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">ll</span><span class="plain-syntax">) </span><span class="identifier-syntax">ll</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">entry_kind</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Kinds::unary_construction_material</span><span class="plain-syntax">(</span><span class="identifier-syntax">K</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="identifier-syntax">internal_error</span><span class="plain-syntax">(</span><span class="string-syntax">"no list appears at this point"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">ll</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">explicitly_cast</span><span class="plain-syntax"> = </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>

<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="function-syntax">Lists::length_of_ll</span><span class="plain-syntax">(</span><span class="identifier-syntax">wording</span><span class="plain-syntax"> </span><span class="identifier-syntax">W</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">incipit</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Wordings::first_wn</span><span class="plain-syntax">(</span><span class="identifier-syntax">W</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">literal_list</span><span class="plain-syntax"> *</span><span class="identifier-syntax">ll</span><span class="plain-syntax"> = </span><a href="3-ll.html#SP6" class="function-link"><span class="function-syntax">Lists::find_literal</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">incipit</span><span class="plain-syntax">+1);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">ll</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) </span><span class="identifier-syntax">internal_error</span><span class="plain-syntax">(</span><span class="string-syntax">"no list appears at this point"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">count</span><span class="plain-syntax"> = </span><span class="constant-syntax">0</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">llist_entry</span><span class="plain-syntax"> *</span><span class="identifier-syntax">lle</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="identifier-syntax">lle</span><span class="plain-syntax"> = </span><span class="identifier-syntax">ll</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">first_llist_entry</span><span class="plain-syntax">; </span><span class="identifier-syntax">lle</span><span class="plain-syntax">; </span><span class="identifier-syntax">lle</span><span class="plain-syntax"> = </span><span class="identifier-syntax">lle</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">next_llist_entry</span><span class="plain-syntax">)</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">count</span><span class="plain-syntax">++;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">count</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<nav role="progress"><div class="progresscontainer">
    <ul class="progressbar"><li class="progressprev"><a href="3-tt.html">&#10094;</a></li><li class="progresschapter"><a href="P-wtmd.html">P</a></li><li class="progresschapter"><a href="1-vm.html">1</a></li><li class="progresschapter"><a href="2-spc.html">2</a></li><li class="progresscurrentchapter">3</li><li class="progresssection"><a href="3-pl.html">pl</a></li><li class="progresssection"><a href="3-lp.html">lp</a></li><li class="progresssection"><a href="3-lrn.html">lrn</a></li><li class="progresssection"><a href="3-lvn.html">lvn</a></li><li class="progresssection"><a href="3-tod.html">tod</a></li><li class="progresssection"><a href="3-ul.html">ul</a></li><li class="progresssection"><a href="3-tt.html">tt</a></li><li class="progresscurrent">ll</li><li class="progresschapter"><a href="4-ets.html">4</a></li><li class="progresschapter"><a href="5-dsh.html">5</a></li><li class="progressnext"><a href="4-ets.html">&#10095;</a></li></ul></div>
</nav><!-- End of weave -->

		</main>
	</body>
</html>

